package com.zerotwo.exam.center.model;

import com.alibaba.druid.sql.ast.statement.SQLCreateViewStatement;
import com.baomidou.mybatisplus.annotation.*;

import com.zerotwo.exam.base.BaseEntity;
import com.zerotwo.exam.center.enums.QuestionTypeEnum;
import com.zerotwo.exam.center.enums.QuestionVisibleEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Range;

import javax.persistence.Column;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;


/**
 * @author 02
 * @version 1.0
 * @Date 2024/7/5
 * @Description 题目信息
 */
@Getter
@Setter
@TableName("eq_question")
@Schema(name = "Question", description = "题目信息")
@Data
public class Question extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    @NotBlank(message = "题目名称不能空~")
    @Schema(description = "题目名称")
    @Column(name = "content")
    private String content;

    @NotNull(message = "题目名称不能空~")
    @Schema(description = "题目类型：0：单选、1：多选、2：判断、3：填空、4：主观")
    private QuestionTypeEnum type;

    @Schema(description = "题目解析")
    private String analysis;

    @Range(min = 0,max = 5,message = "题目难度应在0~5之间")
    @Schema(description = "题目难度")
    private Integer difficulty;

    @Range(min = 1,max = 100,message = "题目分值应在1~100分之间")
    @Schema(description = "题目分值")
    private Float score;

    @Schema(description = "是否公开：0:自己、1：课程、2：公开")
    private QuestionVisibleEnum isPublic;

    @Schema(description = "课程id")
    private Integer courseId;

    @Schema(description = "题目标签id")
    private Integer tagId;

    @Schema(description = "教师id")
    private Integer teacherId;

    //不是此表的字段
    @TableField(exist = false)
    @Column(name = "content")
    @Schema(description = "选项内容\n" +
            "选择性题目：为选项\n" +
            "填空题/客观题：null\n" +
            "文件题：为文件类型\n" +
            "代码题：为语言类型\n")
    private String contents;

    @TableField(exist = false)
    @Schema(description = "题目id")
    private Integer questionId;

    @TableField(exist = false,updateStrategy = FieldStrategy.IGNORED)
    @Schema(description = "选项答案：\n" +
            "选择性题目：非null就是正确答案\n" +
            "填空题/客观题：为正确答案\n" +
            "文件题：为文件答案\n" +
            "代码题：为代码执行结果")
    private String answer;
}
